home *** CD-ROM | disk | FTP | other *** search
- /*
- ** CTelnetInterpreter.h
- **
- ** TurboTCP support library
- ** Generic Telnet protocol interpreter
- **
- ** Copyright © 1993, FrostByte Design / Eric Scouten
- **
- */
-
-
- #pragma once
-
- #include "CTCPSessionDoc.h"
- #include "Telnet.protocol.h"
-
- CLASS CApplication;
-
-
- // state variable for the Telnet command parser
-
- typedef unsigned char uchar;
- typedef enum TelnetState {
- normalChar, // interpret as character
- gotIAC, // received an IAC character
- gotSB, // in subnegotiation
- gotWILL, // received a WILL option
- gotWONT, // received a WONT option
- gotDO, // received a DO option
- gotDONT, // received a DONT option
- gotIACinSB // received IAC while in SB
- } TelnetState;
-
- #define sbBfrMax 80 // max size of subnegotiation buffer
- #define lineBfrMax 80 // max size of line buffer
-
-
- /*______________________________________________________________________
- **
- ** CTelnetInterpreter
- **
- ** This abstract class is a specialized TCP session document. It provides the basic
- ** functionality of a Telnet protocol interpreter. It may be used to implement command-line
- ** protocols which are based on the Telnet protocol (i.e., NNTP or FTP).
- **
- ** This class provides no user interface behaviors and assumes no character-based
- ** terminal. You will need to subclass this class to interpret the specific protocol
- ** you are implementing.
- **
- ** NOTE: This class is provided only as a convenience. You need not include it in your project.
- **
- */
-
- class CTelnetInterpreter : public CTCPSessionDoc {
-
- protected:
- TelnetState itsState; // current command parser state
- short sbBfrIndex; // current index to subnegotiation buffer
- uchar sbBfr [sbBfrMax]; // subnegotiation buffer
- short lineBfrIndex; // current index to subnegotiation buffer
- uchar lineBfr [lineBfrMax]; // subnegotiation buffer
- Boolean useLineBfr; // hold all characters until full line received
- Boolean showDebug; // show debugging codes
-
-
- // initialization
-
- public:
- void ITelnetInterpreter (CApplication *aSupervisor, Boolean printable, long recBufferSize,
- b_16 theDefaultPort, short autoReceiveSize, short autoReceiveNum);
-
-
- // data handling methods
-
- virtual void HandleDataArrived (Ptr theData, b_16 theDataSize, Boolean isUrgent);
- virtual void HandleNVTChar (char theChar);
- virtual void HandleNVTLine (char *theLine);
-
-
- // Telnet command handling
-
- virtual void ReceivedIAC (uchar theCommand);
- virtual void ReceivedWill (uchar theOption);
- virtual void ReceivedWont (uchar theOption);
- virtual void ReceivedDo (uchar theOption);
- virtual void ReceivedDont (uchar theOption);
- virtual void ReceivedBRK (void);
- virtual void ReceivedSynch (void);
- virtual void ReceivedIP (void);
- virtual void ReceivedAO (void);
- virtual void ReceivedAYT (void);
- virtual void ReceivedEC (void);
- virtual void ReceivedEL (void);
- virtual void ReceivedGA (void);
- virtual void ReceivedSB (uchar theChar);
- virtual void ReceivedSE (void);
-
-
- // debugging methods
-
- virtual void PrintDebugStr (char *theDebugStr);
- virtual void PrintDebugCharNum (char theChar, char leftBracket, char rightBracket);
-
- };